import {
  WebSocketGateway,
  SubscribeMessage,
  WebSocketServer,
} from '@nestjs/websockets';
import { Server } from 'socket.io';

@WebSocketGateway()
export class ChatGateway {
  @WebSocketServer() server: Server;

  @SubscribeMessage('send_message')
  handleMessage(client: any, payload: any): string {
    this.server.emit('message', payload); // 广播消息给所有客户端
    return 'Message received';
  }
}
